package com.bangdream.michelia.view.adapter;


import android.support.v4.content.ContextCompat;
import android.text.Html;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bangdream.michelia.R;
import com.bangdream.michelia.entity.LiveBean;
import com.bangdream.michelia.entity.MessageBean;
import com.bangdream.michelia.utils.ImageLoadUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by zhouyi
 */

public class LiveAdapter extends BaseQuickAdapter<LiveBean,BaseViewHolder> {
    public LiveAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, LiveBean item) {
        ImageLoadUtils.ImageLoad(mContext,item.getCover(),(ImageView) helper.getView(R.id.ivIcon),R.mipmap.zhibo);
        helper.setText(R.id.tvTitle, item.getName()+"");
        helper.setText(R.id.tvText, Html.fromHtml(item.getContent())+"");
        TextView tvState = helper.getView(R.id.tvState);
        TextView tvStartTime = helper.getView(R.id.tvStartTime);

        if(item.getTimeStateName()!=null&&item.getTimeStateName().contains("结束")){

            tvState.setBackground(ContextCompat.getDrawable(mContext,R.drawable.cutting_gray_bg));
            tvStartTime.setText("直播时间："+item.getStartTime());
        }else {
            tvStartTime.setText("开始时间："+item.getStartTime());
            tvState.setBackground(ContextCompat.getDrawable(mContext,R.drawable.cutting_red_bg));
        }
        tvState.setText(item.getTimeStateName()+"");

    }
}
